<?php

    /*
    * Request get list Categories in HaiHuocTheThao application
    * Author   ThanhTV
    * Email    tranthanhepu@gmail.com
    * date     Jun 27, 2013
    */

    define("index", true);
    error_reporting(1);

    /* Include file */
    include "conf/config.php";   
    include "db/mysql.php";	
    /*End include file*/        
           
    $db = new database();
    $db -> db = array('host'=>$config['dbhost'], 'user'=>$config['dbuser'], 'pass'=>$config['dbpass'], 'db'=>$config['dbname']);
    $db -> connect();
    $db -> query("set names utf8");          
        
    $sql = "SELECT * FROM `category` ORDER BY `order` ASC"; 
    $rs = $db->query($sql);
    $result = $db->fetch_all($rs);
           
    $arr_result['LIST_CATEGORIES'] = array();
    foreach($result as $k => $v)
    {
        $arr_result['LIST_CATEGORIES']['CATE'][] = array(
            'id'            => $v['id'],
            'name'          => $v['name'],
            'thumb'         => $v['thumb'],
            'order'         => $v['order'],
            'payment'       => $v['payment'],
            'date_create'   => $v['date_create']
        );
    }
//    print_r($arr_result);
    echo utf8_encode( json_encode($arr_result) );
?>